import React from 'react'
import './register.model.css'
import { Button, Form, Input } from 'antd'
import axios from 'axios';
function Regiter() {
    const onFinishFailed = (errorInfo) => {
        console.log('Failed:', errorInfo);
    };
    const onFinish = (values) => {
        console.log('Success:', values);
        // http.post('http://173.0.36.201:8888/api/user/login',{
        //   username:values.username,
        //   password:values.password
        // })
        // .then(res=>{
        //   console.log(res)
        // })
        // .catch(err=>{})
        // fetch('http://173.0.36.201:8888/api/user/login',{
        //   headers:{"Content-Type":"application/json"},
        //   method:"post",
        //   body:`username=${values.username}$password=${values.password}`
        // }).then(res=>res.text()) //请求得到的数据转换为text
        // .then(res=>{
        //     console.log(res)   //打印输出
        // })
        // .catch(err=>{    //错误打印
        //     console.log(err)
        // })
        axios.post("/api/user/register", {
          
            username:values.username,
            password:values.password,
            realName:values.realName
        }).then(res => {
            console.log(res)
        })
            .catch(err => { })
    };
    return (
        <div className='Login_app'>
            <Form
                name="basic"
                labelCol={{
                    span: 8,
                }}
                wrapperCol={{
                    span: 16,
                }}
                style={{
                    maxWidth: 600,
                }}
                initialValues={{
                    remember: true,
                }}
                onFinish={onFinish}
                onFinishFailed={onFinishFailed}
                autoComplete="off"
            >
                <Form.Item
                    label="Username"
                    name="username"
                    rules={[
                        {
                            required: true,
                            message: 'Please input your username!',
                        },
                    ]}
                >
                    <Input />
                </Form.Item>

                <Form.Item
                    label="Password"
                    name="password"
                    rules={[
                        {
                            required: true,
                            message: 'Please input your password!',
                        },
                    ]}
                >
                    <Input.Password />
                </Form.Item>
                <Form.Item label='realName' name='realName'>
                    <Input />
                </Form.Item>


                <Form.Item
                    wrapperCol={{
                        offset: 8,
                        span: 16,
                    }}
                >
                    <Button type="primary" htmlType="submit">
                        Submit
                    </Button>
                </Form.Item>
            </Form>
        </div>
    )
}

export default Regiter
